package me.zhengjie.modules.gu_excel.controller;

import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.gu_excel.entity.DataExcelBase;
import me.zhengjie.modules.gu_excel.service.HandleExcelService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(value = "/gu/excel")
@RequiredArgsConstructor
@Api(tags = "数据：excel相关接口")
public class ExcelController {

    @Resource
    private HandleExcelService handleExcelService;

    @PostMapping("/uploadExcel")
    public void uploadExcel(@RequestParam("file") MultipartFile file) throws IOException {
        handleExcelService.uploadExcel(file);
    }

    @GetMapping("/getExcelInfo")
    @ResponseBody
    public List<Map<String, String>> getExcelInfo(int excelId) throws IOException {
        return handleExcelService.getExcelInfo(excelId);
    }

    @GetMapping("/getExcelDataBase")
    @ResponseBody
    public List<DataExcelBase> getExcelDataBase() throws IOException {
        return handleExcelService.getExcelDataBase();
    }
}
